using HKB.Common.MobileMessage_56;
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
namespace HKB.Common
{
	public class MobileMessage
	{
		private WebServiceInterfaceSoapClient _ws_56 = null;
		private string username_56 = "";
		private string password_56 = "";
		private string cid_56 = "";
		public WebServiceInterfaceSoapClient ws_56
		{
			get
			{
				if (this._ws_56 == null)
				{
					this._ws_56 = new WebServiceInterfaceSoapClient();
				}
				return this._ws_56;
			}
		}
		public bool Send(string ReceiveNumber, string Content, string UserName)
		{
			return false;
		}
		public bool Send()
		{
			return false;
		}
		public int SendMSG(string mobilenumber, string message)
		{
			string text = string.Format("http://sms.webchinese.cn/web_api/?Uid=账号&Key=接口密钥&smsMob={0}&smsText={1}", mobilenumber, message);
			string text2 = null;
			text = HttpUtility.UrlEncode(text);
			int result;
			if (text == null || text.Trim().ToString() == "")
			{
				result = 0;
			}
			else
			{
				try
				{
					HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(text);
					httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
					httpWebRequest.Method = "GET";
					httpWebRequest.Timeout = 1800000;
					WebResponse response = httpWebRequest.GetResponse();
					System.IO.Stream responseStream = response.GetResponseStream();
					System.IO.StreamReader streamReader = new System.IO.StreamReader(responseStream, System.Text.Encoding.Default);
					text2 = streamReader.ReadToEnd();
				}
				catch (System.Exception)
				{
					text2 = null;
				}
				if (text2 == null || text2 == "")
				{
					result = 0;
				}
				else
				{
					result = System.Convert.ToInt32(text2);
				}
			}
			return result;
		}
		public int SendMSG_56(string mobilenumber, string message)
		{
			string sendtime = "";
			string smsnumber = "";
			return this.ws_56.SendNote(mobilenumber, message, this.username_56, this.password_56, this.cid_56, sendtime, smsnumber);
		}
		public int ReturnUserFullMoney_56()
		{
			return this.ws_56.ReturnUserFullMoney(this.username_56, this.password_56, this.cid_56);
		}
		public int EditUserPwd(string oldpwd, string newpwd)
		{
			return this.ws_56.EditUserPwd(this.username_56, oldpwd, newpwd, this.cid_56);
		}
		public bool sendfetion(string sendNumber, string sendPassword, string receiveNumber, string Content)
		{
			string requestUriString = string.Format("https://quanapi.sinaapp.com/fetion.php?u={0}&p={1}&to={2}&m={3}", new object[]
			{
				sendNumber,
				sendPassword,
				receiveNumber,
				HttpUtility.UrlEncode(Content)
			});
			string text = "";
			try
			{
				HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
				httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
				httpWebRequest.Method = "GET";
				httpWebRequest.Timeout = 1800000;
				WebResponse response = httpWebRequest.GetResponse();
				System.IO.Stream responseStream = response.GetResponseStream();
				System.IO.StreamReader streamReader = new System.IO.StreamReader(responseStream, System.Text.Encoding.Default);
				text = streamReader.ReadToEnd();
			}
			catch (System.Exception ex)
			{
				ex.WriteErrorLog(new string[0]);
				text = "";
			}
			return text.Contains(":0");
		}
	}
}
